package de.jmda.mview;

import java.io.File;

import de.jmda.gui.swing.mvc.ModelBase;
import de.jmda.mview.proj.ProjectModelRepository;
import de.jmda.mview.proj.ProjectModelRepositoryStore;

// does not implement JAXBModelProvider because this model does not need to be
// JAXB serialized. However it provides a project model repository that is JAXB
// serialisable.
public class MViewModel extends ModelBase
{
	private ProjectModelRepository projectModelRepository;
	
	public MViewModel(ProjectModelRepository projectModelRepository)
	{
		super();
		this.projectModelRepository = projectModelRepository;
	}
	
	public ProjectModelRepository getProjectModelRepository()
	{
		return projectModelRepository;
	}

	public boolean updateProjectModelRepository(File projectRepositoryFile)
  {
		ProjectModelRepository projectModelRepository =
				ProjectModelRepositoryStore.load(projectRepositoryFile);

		if (projectModelRepository != null)
		{
			this.projectModelRepository = projectModelRepository;
			return true;
		}
		
		System.err.println("failure loading project model repository");

		return false;
  }
}